package org.misalen.web.server.controllers;

import org.misalen.annotations.ControllerApi;
import org.misalen.annotations.InterfaceApi;
import org.misalen.web.server.config.ServerResult;
import org.misalen.web.server.forms.ClientVersionForm;
import org.misalen.web.server.result.Empty;
import org.misalen.web.server.util.FormUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@ControllerApi(value = "查看版本及服务", description = "")
@RequestMapping(value = "/v1/client")
public class ClientVersionController extends BaseController {

	@RequestMapping(value = "/version", method = { RequestMethod.POST,
			RequestMethod.GET }, produces = "application/json")
	@InterfaceApi(value = "初始化配置", resultClass = Empty.class)
	public @ResponseBody ServerResult version(@RequestBody ClientVersionForm form) throws Exception {
		FormUtil.validate(form);
		return ServerResult.ok(proClientVersionRepository.getByType(form.getClientType()));
	}

}
